package org.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.domain.Menu;

import java.util.List;

@Mapper
public interface MenuDao extends BaseMapper<Menu> {

    //    List<GrantedAuthority> getGrantedAuthority(Integer id);
    List<String> getGrantedAuthority(Integer id);

    @Select("select id,name,menu_key from menu")
    List<Menu> getMenus();

    List<Menu> selectByRoleId(int roleId);

    @Delete("delete from role_menu where role_id = #{roleId}")
    int deleteMenusByRoleId(int roleId);

    int saveMenusByRoleId(@Param("roleId") int roleId,@Param("menuList") List<Integer> menuList);
}
